﻿/***************************************************************************
 *		ElGee Google Chart API Helper
 *		Copyright(C) 2011 by Laurent Geffroy lgeffroy@gmail.com
 * 
 *		This program is free software; you can redistribute it and/or 
 *		modify it under the terms of the GNU General Public License as
 *		published by the Free Software Foundation; either version 2 of 
 *		the License, or (at your option) any later version.
 *		
 *		This program is distributed WITHOUT ANY WARRANTY; without even the
 *		implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *		See the GNU General Public License for more details.
 *	
 *      For particular licensing, please contact me at lgeffroy@gmail.com
 *****************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;

namespace ElGee.Google.Charts
{
    /// <summary>
    /// Chart Style Class
    /// </summary>
    public class BaseChartStyle : ChartBase
    {
        /// <summary>
        /// Gets or sets the colors.
        /// The colors to use for the chart elements. An array of strings, where each element is an HTML color string
        /// </summary>
        /// <value>colors</value>
        public List<String> Colors { get; set; }

        /// <summary>
        /// Gets or sets the height.
        /// Height of the chart, in pixels.
        /// </summary>
        /// <value>height</value>
        public UInt32 Height { get; set; }

        /// <summary>
        /// Gets or sets the width.
        /// Width of the chart, in pixels.
        /// </summary>
        /// <value>width</value>
        public UInt32 Width { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseChartStyle"/> class.
        /// </summary>
        public BaseChartStyle()
        {
            Colors = new List<string>();
            Height = 0;
            Width = 0;
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            // Handle the colors 
            if ((Colors != null) && (Colors.Count > 0))
            {
                sb.Append("colors: [");
                for (int i = 0; i < Colors.Count; i++)
                {
                    sb.Append("'").Append(SecureString(Colors[i])).Append("',");
                }
                // Removing the last comma of the colors
                sb.Remove(sb.Length - 1, 1);
                sb.Append("],");
            }


            if (Height > 0)
                sb.Append("height: ").Append(Height).Append(",");

            if (Width > 0)
                sb.Append("width: ").Append(Width).Append(",");

            // Removing the last comma
            sb.Remove(sb.Length - 1, 1);

            return sb.ToString();
        }
    }

}
